package Interface;
import lejos.nxt.*;
import lejos.nxt.comm.*;
import java.io.*;


public class BTReceive {

	public static void main(String [] args)  throws Exception 
	{
		
		while (true)
		{
			LCD.drawString("Waiting for connection",0,0);
			LCD.refresh();

	        BTConnection btc = Bluetooth.waitForConnection();
	        
			LCD.clear();
			LCD.drawString("connected...",0,0);
			LCD.refresh();	

			DataInputStream dis = btc.openDataInputStream();
			DataOutputStream dos = btc.openDataOutputStream();
			
			for(int i=0;i<10;i++) {
				
				dos.writeBytes("test" + i);
				dos.flush();
			}
			
			dis.close();
			dos.close();
			Thread.sleep(100); // wait for data to drain
			LCD.clear();
			LCD.drawString("close connection",0,0);
			LCD.refresh();
			btc.close();
			
		}
	}
}

